/** @mainpage AI Tester Server
*
* @author Tomas Hubik
*
* <br>
*
*
* @section intro Introduction
*
* This application is a server for network games with AI Tester.
*
* <br>
* <hr>
* <br>
*
* @section requirements Requirements
*
* - Qt framework 4.4.0
* - AI Tester 1.1 for network games
*
* <br>
* <hr>
* <br>
* 
*
* @section architecture Architecture
*
* The application consists of two main components, that are representated as singletons:
*
* - server_gui: This contains api funtions to handle whole %gui. It is implemented using Qt Widgets, but system architecture makes possible to
*               replace it by another, for example text %gui, that can be used on systems, where Qt Widgets are not supported.
*
* - server_listener: All netwwork communication with the server is managed by this client. It receives and decodes all messages and forwards them
*                    to game if needed. It is created only when playing over network.
*
* <br>
*
*
* @subsection server_gui Server GUI
*
* On application start, main_widget is set as central widget of the %gui. Each button, except About buttons and Exit one, will change the central widget.
*
* - <i>Start %Server</i>: To setup_widget - here are the basic parameters of listener set, maps loaded and listener created by
*                                          server_listener::create_listener( unsigned int plrs ) and started by
*                                          server_listener::start_listener( unsigned int port )
* - <i>About Qt</i>: Shows About Qt window
* - <i>About</i>: Shows about AI Tester window
* - <i>Exit</i>: Exits the application
*
* When the listener is started, listener_widget is set as central widget of the main window and shows statuses of connected clients.
*
* <br>
*
*
* @subsection network Network
*
* For all network communication takes care server_listener singleton. It contains class Server, that is listening for incomming connections.
* All clients are handled by class client_proxy. When some message arrives, client_proxy::receive_message() slot is invoked and message will be resend
* to Server to processing.
*
* When some client connects, his proxy is being created and all slots and singnals are connectet to his proxy. "ACCEPTED" message with his id is
* immediately sent and also map and optionally obejcts are sent.
*
* Messages has fixed structure. Message type, then '=' and then message content.
*
* There are only 4 of types of messages, that can be received:
* - <b>SET_PLAYER</b>: contains network players name in "", players type and id. Processing this message sets new labels to listener_widget and
*                      stores message to Server::pending_messages
* - <b>OK</b>: contains information, what the client receives. 0->map received, 1->objects received, 3->connected player info received
*              server counts these messages and determines if all clients already received all necessary message, so game can be started
* - <b>ACTION</b>: this is message containing game commands ( player id ':' command ) and server only resends it to other clients
* - <b>ERROR</b>: this type of message contains only error message, that is displayed via server_gui::show_client_error( unsigned int c, const string& e )
*
* When any client disconnects, server will automaticly restart itself in 2 seconds!
*
* Here is a scheme of commands flow in the application and over network. AI Algorithm or Human produces command. Network_client will add client's id to
* the command and send it to the server.
*
* \image html server-client_messages.jpeg
*
*
*/